package com.edu.exam.entity.assessment.plan;

import com.edu.exam.enums.assessment.plan.AssessmentPlanAuditResult;
import com.edu.exam.enums.assessment.plan.AuditStatus;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 考试计划审核记录实体类
 * 所属模块：B-05 考核计划管理模块
 * 对应数据库表：exam_plan_audit_record
 *
 * <p>考试计划审核记录实体，记录计划的完整审核历史。
 * 每个审核环节都会生成相应记录，包含审核人、审核结果、
     审核意见、审核时间等信息。</p>
 *
 * @author 系统生成
 * @version 2.0
 * @since 2025-11-09
 */
@Entity
@Table(name = "exam_plan_audit_record")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExamPlanAuditRecord {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 考试计划ID
     */
    @Column(name = "plan_id", nullable = false)
    private Long planId;

    /**
     * 审核流程ID
     */
    @Column(name = "audit_process_id")
    private Long auditProcessId;

    /**
     * 审核节点编码
     */
    @Column(name = "node_code", length = 50, nullable = false)
    private String nodeCode;

    /**
     * 审核节点名称
     */
    @Column(name = "node_name", length = 100, nullable = false)
    private String nodeName;

    /**
     * 审核人角色
     */
    @Column(name = "auditor_role", length = 50, nullable = false)
    private String auditorRole;

    /**
     * 审核人ID
     */
    @Column(name = "auditor_id", nullable = false)
    private Long auditorId;

    /**
     * 审核人姓名
     */
    @Column(name = "auditor_name", length = 100, nullable = false)
    private String auditorName;

    /**
     * 审核状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "audit_status", length = 20, nullable = false)
    private AuditStatus auditStatus;

    /**
     * 审核结果
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "audit_result", length = 20)
    private AssessmentPlanAuditResult auditResult;

    /**
     * 审核意见
     */
    @Column(name = "audit_comment", length = 2000)
    private String auditComment;

    /**
     * 接收时间
     */
    @Column(name = "received_time")
    private LocalDateTime receivedTime;

    /**
     * 审核时间
     */
    @CreatedDate
    @Column(name = "audit_time", nullable = false, updatable = false)
    private LocalDateTime auditTime;

    /**
     * 审核时长（分钟）
     */
    @Column(name = "audit_duration")
    private Integer auditDuration;

    /**
     * 审核附件路径
     */
    @Column(name = "attachment_path", length = 500)
    private String attachmentPath;

    /**
     * 审核说明
     */
    @Column(name = "audit_description", length = 1000)
    private String auditDescription;

    /**
     * 前置节点ID
     */
    @Column(name = "previous_node_id")
    private Long previousNodeId;

    /**
     * 下一节点ID
     */
    @Column(name = "next_node_id")
    private Long nextNodeId;

    /**
     * 节点顺序
     */
    @Column(name = "node_order")
    private Integer nodeOrder;

    /**
     * 是否为最后节点
     */
    @Column(name = "is_last_node", nullable = false)
    private Boolean isLastNode;

    /**
     * 审核人部门
     */
    @Column(name = "auditor_department", length = 200)
    private String auditorDepartment;

    /**
     * 审核人职位
     */
    @Column(name = "auditor_position", length = 100)
    private String auditorPosition;

    /**
     * 审核人IP地址
     */
    @Column(name = "auditor_ip", length = 50)
    private String auditorIp;

    /**
     * 委托审核人ID
     */
    @Column(name = "delegated_auditor_id")
    private Long delegatedAuditorId;

    /**
     * 委托审核人姓名
     */
    @Column(name = "delegated_auditor_name", length = 100)
    private String delegatedAuditorName;

    /**
     * 委托原因
     */
    @Column(name = "delegation_reason", length = 500)
    private String delegationReason;

    /**
     * 特殊标记
     */
    @Column(name = "special_flag", length = 20)
    private String specialFlag;

    /**
     * 版本号
     */
    @Column(name = "version", nullable = false)
    private Integer version = 1;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}
